package com.chen.jwt.service;

import com.chen.jwt.entity.User;
import com.chen.jwt.mapper.UserMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @author 若晨
 * @version 1.0.0
 * @ClassName UserServiceImpl.java
 * @Description TODO
 * @createTime 2022年08月02日 19:40:00
 */
@Service
public class UserServiceImpl implements UserService{
    @Autowired
    private UserMapper userMapper;

    @Override
    public User login(User user) {
    //根据接收的用户名和密码查询数据库
        User result = userMapper.login(user);

        if (result!=null){
            return result;
        }

        throw new RuntimeException("登录失败");
    }


    @Override
    public User getById(Integer id) {

        User user = userMapper.selectById(id);

        return user;
    }


}
